# #!/bin/env python
# # def LoginSucess(creditId):
# # 	flag = 0
# # 	while flag <= 5:
# # 		print '''
# # \t=========欢迎用户%s登录到信用卡中心=========
# # \t\t1.取现\t\t2.查询\t\t
# # \t\t3.还款\t\t4.转账\t\t
# # \t\t5.购物\t\t6.退出\t\t
# # ''' % creditId
# # 		choice = int(raw_input('''请选择指令:''').strip())
# # 		if choice >= 1 and choice <= 6:
# # 			if choice == 1:
# # 				print '1'
# # 			if choice == 2:
# # 				print '2'
# # 			if choice == 3:
# # 				print '3'
# # 			if choice == 4: 
# # 				print '4'
# # 			if choice == 5:
# # 				print '5'
# # 			if choice == 6:
# # 				print '6'
# # 		else:
# # 			flag += 1
# # 			print "你输入的指令不在规定范围内,请重新输入![1-6]"

# # LoginSucess('test')
# # creditId = '1018584989'
# # import json
# # # f = file('users.txt','r')
# # # for list in f.readlines():
# # # 	json.dump(list,open('test.json','a+'))
# # d = json.load(open('test.json','r'))
# # print d
# # # 	print list
# # # 	print "list['ID']:",list['ID']
# # # 	# if list['ID'] == creditId:
# # # 	# while flag <= 3:
	
# # # 	# 	if list['Pass'] == creditPass:
# # # 	# 		print right
# # 	# 	else:
# # 	# 		flag += 1
# # 	# 		print "你输入的密码有误,请重新输入!"
# # 	# 		break
# # 	# else:
# # 	# 	flag += 1
# # 	# 	print "你输入的信用卡号有误,请重新输入!"
# # 	# 	break{'ID':1018584989,'Pass':123456,'Yue':15000}
# # 	# print "你的输入错误次数已达3次,登录程序即将退出!"
# # 	# main.welcome()
# # f.close()
# # test = {'ID':'1018584989','Pass':123456,'Yue':15000}
# # print "test['ID']:",test['ID']
# # print "tets['Pass']:",test['Pass']
# # print "test['Yue']:",test['Yue']
# # print str(test)
# # print type(test)

# # import json
# # test = open('users.txt','r+')
# # for line in test.readlines():
# # 	print line
# # 	print type(line)
# # 	# print "line['ID']:",line['ID']
# # test.close()
# # import os,sys

# # f = open('shoplist.txt','r')
# # flag = 0
# # choice = 1
# # for line in f.readlines():
# # 	list1 = line.split(' ')
# # 	# print type(int(list1[0]))
# # 	if cmp(choice,list1[0]) == 0:
# # 		print '''
# # ================================================
# # 你已将%s添加到购物车,消费%s元!
# # ================================================
# # ''' % (list1[1],list1[2])
# # f.close()
# # print '退出'
# # import linecache
# # count = 0
# # thefile = open('shoplist.txt', 'rb')
# # while True:
# #     buffer = thefile.read(8192*1024)
# #     if not buffer:
# #         break
# #     count += buffer.count('\n')
# #     print count
# # thefile.close()

# # count = linecache.getline('shoplist.txt',1)
# # print count.split()[1]


# # import shoplogin
# # import linecache
# #获取文件的行数
# # def countnum(object):
# # 	count = 0
# # 	thefile = open('shoplist.txt', 'rb')
# # 	while True:
# # 	    buffer = thefile.read(8192*1024)
# # 	    if not buffer:
# # 	        break
# # 	    count += buffer.count('\n')
# # 	thefile.close()
# # def shopping(choiceshop):
# # 	#获取文件中某一行字符串
# # 	line = linecache.getline('shoplist.txt',choiceshop)
# # 	#将字符串转换成列表
# # 	line = line.split()
# # 	print '''
# # ================================================
# # 你已将%s添加到购物车,消费%s元!
# # ================================================
# # ''' % (line[1],line[2])

# # shopping(2)
# # import linecache
# # import time
# # import random
# # def countnum(filename):
# # 	count = 0
# # 	thefile = open(filename, 'rb')
# # 	while True:
# # 	    buffer = thefile.read(8192*1024)
# # 	    if not buffer:
# # 	        break
# # 	    count += buffer.count('\n')
# # 	thefile.close()
# # 	# print count
# # 	return count
# # def showshopping(title = "购物车"):  #展示购物车信息
# # 	global moneynum 
# # 	print '*****************%s******************'%(title)
# # 	form = '%s\t%s%s%s\t%s'% ('商品名称','单价','*','数量','总价')
# # 	print form
# # 	for num in range(1,countnum('usershoplist.txt')+1):	#countnum() = countnum()+1+1 表示获取的数值+1(实际行数)+1(取值范围+1)
# # 		print '''循环中的num:%d''' % num
# # 		print '''循环中的countnum:%d''' % countnum('usershoplist.txt')
# # 		usershoplistline = linecache.getline('usershoplist.txt',num).strip('\n').split(' ')
# # 		print "%s\t%s%s%s\t\t%s元\n" % (usershoplistline[0],usershoplistline[1],'*','1',usershoplistline[1]),
		
# # 		moneynum += int(usershoplistline[1])
# # 	# print type(usershoplistline[1])
# # 	print '''总额:%d''' % moneynum
# # 	print '''最后的countnum:%d''' % countnum('usershoplist.txt')
# # 	print type(countnum('usershoplist.txt'))
# # 	print '''最后的num:%d''' % num 

# # def orders():
# # 	global moneynum
# # 	#创建订单列表
# # 	usrshophistorylist = open('usrshophistorylist.txt','a')
# # 	create_shopID = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time())) + '' + str(random.randint(100, 200))
# # 	for num in range(1,countnum('usershoplist.txt')+1):	#countnum() = countnum()+1+1 表示获取的数值+1(实际行数)+1(取值范围+1)
# # 		usershoplistline = linecache.getline('usershoplist.txt',num).strip('\n').split(' ')
# # 		form = "%s\t%s\t%s%s%s\t\t%s\n" % (create_shopID,usershoplistline[0],usershoplistline[1],'*','1',usershoplistline[1])
# # 		usrshophistorylist.write(form),
# # 		# moneynum += int(usershoplistline[1])  #将全局变量moneynum进行了修改,其他函数调用这个变量时就会携带修改后的值
# # 	formall = '''需支付金额为: %d 元\n''' % moneynum
# # 	usrshophistorylist.write(formall)
# # 	usrshophistorylist.close()
# # moneynum = 0
# # showshopping()
# # # orders()



# import banklogin
# import shopmanage
# import linecache
# import time

# #取款
# def draw():
# 	#最后一行的索引值 int
# 	lastline = shopmanage.countnum('bank.txt')
# 	#当前余额 str->int
# 	bankYue = int(linecache.getline('bank.txt',lastline).split('\t')[4])
# 	print u"你的信用卡当前余额为:%d元" % bankYue
# 	flag = 0
# 	while flag <= 3:
# 		choicelsit = raw_input('''
# \t================================================\t
# \t\t\t1.继续取款\t\t2.退出\t\t\t
# \t================================================\t
# \t请选择指令进行操作[1/2]:''').strip()
# 		if len(choicelsit) == 0:
# 			flag += 1
# 			print "指令不能为空,请重新输入[1/2]!"
# 		else:
# 			if choicelsit.isdigit():
# 				choicelsit = int(choicelsit)
# 				if choicelsit >= 1 and choicelsit <=2:
# 					if choicelsit == 1:
# 						# 取款条件判断
# 						flag = 0
# 						while flag <= 3:
# 							drawMoney = raw_input('''请输入你要取现的金额[100-%d]:''' % bankYue).strip()
# 							if len(drawMoney) == 0:  #判断用户输入的字符长度
# 								flag += 1
# 								print "金额不能为空,请重新输入[100-%d]!" % bankYue
# 							else: #字符长度不为0
# 								if drawMoney.isdigit(): #判断用户输入的金额是否为纯数字
# 									drawMoney = int(drawMoney) #纯数字转换成整数类型
# 									if drawMoney % 100 == 0: #判断用户输入的整数是否是100的倍数
# 										if drawMoney >= 100 and drawMoney <= bankYue: #判断用户输入的整数是否在余额范围内
# 											# 进行取款操作
# 											bankCar = open('bank.txt','a')
# 											bankDraw = '''%s\t%s\t%d\t%d\n''' %(time.strftime('%Y-%m-%d\t%H:%M:%S',time.localtime(time.time())),'取款',drawMoney,bankYue-drawMoney)
# 											bankCar.write(bankDraw)
# 											bankCar.close()
# 											time.sleep(2)
# 											print "取现成功!请取走你的钞票!"
# 											bankYue -= drawMoney
# 											time.sleep(1)
# 											break
# 										else: #不在余额范围内
# 											# if drawMoney > bankYue: #判断用户输入的整数是否超出余额
# 											print "余额不足,请减少取现数目[100-%d]!" % bankYue
# 									else: #非100的倍数输出异常
# 										flag += 1
# 										print "请输入整百的取现金额[100-%d]!" % bankYue
# 								else: #非纯数字输入异常
# 									flag += 1
# 									print "你的输入有误,金额只接收整百数字,请重新输入[100-%d]!" % bankYue
							
# 					if choicelsit == 2:
# 						print "系统将退出!"
# 						time.sleep(1)
# 						break
# 				else:
# 					flag += 1
# 					print "请输入正确的数字指令[1/2]!"
# 			else:
# 				flag += 1
# 				print "指令仅限整型数字[1/2]!"
# 	else:
# 		print "你输入的错误次数已达3次,系统将退出!"
# def check():
# 	flag = 0
# 	while flag <= 3:
# 		#最后一行的索引值 int
# 		lastline = shopmanage.countnum('bank.txt')
# 		choicelsit = raw_input('''
# \t===================================================\t
# \t\t1.查询余额\t2.查询消费记录\t3.退出\t\t
# \t===================================================\t
# 请选择指令进行操作[1-3]:''').strip()
# 		if len(choicelsit) == 0:
# 			flag += 1
# 			print "指令不能为空,请重新输入[1/2]!"
# 		else:
# 			if choicelsit.isdigit():
# 				choicelsit = int(choicelsit)
# 				if choicelsit >= 1 and choicelsit <= 3:
# 					if choicelsit == 1:
# 						#当前余额 str->int
# 						bankYue = int(linecache.getline('bank.txt',lastline).split('\t')[4])
# 						print "你的信用卡当前余额为:%d元" % bankYue
# 					if choicelsit == 2:
# 						bankhislinenum = shopmanage.countnum('bank.txt')
# 						print "\t=====================消费记录=======================\t"
# 						for line in range(1,bankhislinenum+1):
# 							print '\t%s' % linecache.getline('bank.txt',line),
# 							# print type(line)
# 					if choicelsit == 3:
# 						print "系统将退出!"
# 						time.sleep(1)
# 						break
# 				else:
# 					flag += 1
# 					print "请输入正确的数字指令[1-3]!"
# 			else:
# 				flag += 1
# 				print "指令仅限整型数字[1-3]!"
# 	else:
# 		print "你输入的错误次数已达3次,系统将退出!"
# #还款
# def repayment():
# 	#最后一行的索引值 int
# 	lastline = shopmanage.countnum('bank.txt')
# 	#当前余额 str->int
# 	bankYue = int(linecache.getline('bank.txt',lastline).split('\t')[4])
# 	print u"你的信用卡当前余额为:%d元" % bankYue
# 	flag = 0
# 	while flag <= 3:
# 		choicelsit = raw_input('''
# \t================================================\t
# \t\t\t1.继续还款\t\t2.退出\t\t\t
# \t================================================\t
# \t请选择指令进行操作[1/2]:''').strip()
# 		if len(choicelsit) == 0:
# 			flag += 1
# 			print "指令不能为空,请重新输入[1/2]!"
# 		else:
# 			if choicelsit.isdigit():
# 				choicelsit = int(choicelsit)
# 				if choicelsit >= 1 and choicelsit <=2:
# 					if choicelsit == 1:
# 						repaymoney = raw_input("请输入你的还款金额[1-%d]:" % bankYue).strip()
# 						if len(repaymoney) == 0:
# 							flag += 1
# 							print "金额不能为空,请重新输入[1-%d]!" % bankYue
# 						else:
# 							if repaymoney.isdigit():
# 								repaymoney = int(repaymoney)
# 								if repaymoney >= 1 and repaymoney <= bankYue:
# 									bankCar = open('bank.txt','a')
# 									bankRepay = '''%s\t%s\t%d\t%d\n''' %(time.strftime('%Y-%m-%d\t%H:%M:%S',time.localtime(time.time())),'还款',repaymoney,bankYue-repaymoney)
# 									bankCar.write(bankRepay)
# 									bankCar.close()
# 									time.sleep(2)
# 									print "还款成功!"
# 									# bankYue -= bankRepay
# 									time.sleep(1)
# 									break
# 								else:
# 									print "余额不足,请重新输入[1-%d]!" % bankYue
# 							else:
# 								flag += 1
# 								print "你的输入有误,金额只接收整数,请重新输入[1-%d]!" % bankYue
# 					if choicelsit == 2:
# 						print "系统将退出!"
# 						time.sleep(1)
# 						break
# 				else:
# 					flag += 1
# 					print "请输入正确的数字指令[1/2]!"
# 			else:
# 				flag += 1
# 				print "指令仅限整型数字[1/2]!"
# 	else:
# 		print "你输入的错误次数已达3次,系统将退出!"
# #转账
# def transfer():
# 	#最后一行的索引值 int
# 	lastline = shopmanage.countnum('bank.txt')
# 	#当前余额 str->int
# 	bankYue = int(linecache.getline('bank.txt',lastline).split('\t')[4])
# 	print u"你的信用卡当前余额为:%d元" % bankYue
# 	flag = 0
# 	while flag <= 3:
# 		choicelsit = raw_input('''
# \t================================================\t
# \t\t\t1.继续转账\t\t2.退出\t\t\t
# \t================================================\t
# \t请选择指令进行操作[1/2]:''').strip()
# 		if len(choicelsit) == 0:
# 			flag += 1
# 			print "指令不能为空,请重新输入[1/2]!"
# 		else:
# 			if choicelsit.isdigit():
# 				choicelsit = int(choicelsit)
# 				if choicelsit >= 1 and choicelsit <=2:
# 					if choicelsit == 1:
# 						transmoney = raw_input("请输入你的转账金额[1-%d]:" % bankYue).strip()
# 						if len(transmoney) == 0:
# 							flag += 1
# 							print "金额不能为空,请重新输入[1-%d]!" % bankYue
# 						else:
# 							if transmoney.isdigit():
# 								transmoney = int(transmoney)
# 								if transmoney >= 1 and transmoney <= bankYue:
# 									bankCar = open('bank.txt','a')
# 									bankTrans = '''%s\t%s\t%d\t%d\n''' %(time.strftime('%Y-%m-%d\t%H:%M:%S',time.localtime(time.time())),'还款',transmoney,bankYue-transmoney)
# 									bankCar.write(bankTrans)
# 									bankCar.close()
# 									time.sleep(2)
# 									print "转账成功!"
# 									# bankYue -= bankRepay
# 									time.sleep(1)
# 									break
# 								else:
# 									print "余额不足,请重新输入[1-%d]!" % bankYue
# 							else:
# 								flag += 1
# 								print "你的输入有误,金额只接收整数,请重新输入[1-%d]!" % bankYue
# 					if choicelsit == 2:
# 						print "系统将退出!"
# 						time.sleep(1)
# 						break
# 				else:
# 					flag += 1
# 					print "请输入正确的数字指令[1/2]!"
# 			else:
# 				flag += 1
# 				print "指令仅限整型数字[1/2]!"
# 	else:
# 		print "你输入的错误次数已达3次,系统将退出!"

# #支付
# def shoppay():
# 	#当前余额 str->int
# 	bankYue = int(linecache.getline('bank.txt',shopmanage.countnum('bank.txt')).split('\t')[4])
# 	#最后一行的索引值 int
# 	lastline = shopmanage.countnum('usrshophistorylist.txt')
# 	shopID = linecache.getline('usrshophistorylist.txt',lastline-1).split('\t')[0]
# 	shoppaymoney = int(linecache.getline('usrshophistorylist.txt',lastline).split(' ')[1])
# 	flag = 0
# 	while flag <= 3:
# 		choicelsit = raw_input("你即将为订单%s进行支付%d元,请你确认[y/n]:" % (shopID,shoppaymoney)).strip()
# 		if len(choicelsit) == 0:
# 			flag += 1
# 			print "输入不能为空,请重新输入[y/n]确认!"
# 		else:
# 			if choicelsit == 'Y' or choicelsit == 'y' or choicelsit == 'N' or choicelsit == 'n':
# 				if choicelsit == 'y' or choicelsit == 'Y':
# 					# 进行取款操作
# 					bankCar = open('bank.txt','a')
# 					bankDraw = '''%s\t%s\t%d\t%d\n''' %(time.strftime('%Y-%m-%d\t%H:%M:%S',time.localtime(time.time())),'购物',shoppaymoney,bankYue-shoppaymoney)
# 					bankCar.write(bankDraw)
# 					bankCar.close()
# 					time.sleep(2)
# 					print "支付成功!"
# 					# bankYue -= drawMoney
# 					time.sleep(1)
# 					break
# 				if choicelsit == 'n' or choicelsit == 'N':
# 					print '你本次确认不结算订单%s!' % shopID
# 					break
# 			else:
# 				flag += 1
# 				print "你的输入有误,请重新输入[y/n]!"
# 	else:
# 		print "你输入的错误次数已达3次,系统将退出!"
# 		time.sleep(1)

	


# # draw()
# # check()
# # shoppay()
# # repayment()
# transfer()


def countnum(filename):
	files = open(filename)
	data = files.read()
	files.close()
	return data.count('\n')

countnum('bank.txt')